package com.conlin.learn.io;

import com.conlin.learn.common.annotation.LogExecutionTime;
import com.conlin.learn.common.contant.Contant;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class ReadFileAnno {

    @LogExecutionTime
    public void doSomething() {

        String path = "J:\\java_work\\files\\ioTest.txt";
        String outPath = "J:\\java_work\\files\\ioOutTest.txt";

        try (FileInputStream fileInputStream = new FileInputStream(path);
             FileOutputStream fileOutputStream = new FileOutputStream(outPath)) {

            byte[] bytes = new byte[Contant.BYTE_LENGTH];
            int c;
            while ((c = fileInputStream.read(bytes)) != -1) {
                String temp = new String(bytes, 0, c);
                System.out.println(temp);

                fileOutputStream.write(bytes, 0, c);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
